using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class LevelUI : MonoBehaviour
{
    public GameObject unlockGo;
    public GameObject lockGo;

    public Text levelNumberText;
    public GameObject star0Go;
    public GameObject star1Go;
    public GameObject star2Go;
    public GameObject star3Go;
        
    private MapLevelUI _mapLevelUI;
    private int levelID;

    //显示关卡信息
    public void Show(int starCount, int levelID, MapLevelUI mapLevelUI)
    {
        this._mapLevelUI = mapLevelUI;
        this.levelID = levelID;
        //-1锁状态，>0解锁状态
        if (starCount < 0)
        {
            lockGo.SetActive(true);
            unlockGo.SetActive(false);
        }
        else
        {
            lockGo.SetActive(false);
            unlockGo.SetActive(true);
            levelNumberText.text = levelID.ToString();
            star0Go.gameObject.SetActive(starCount >= 0);
            star1Go.gameObject.SetActive(starCount >= 1);
            star2Go.gameObject.SetActive(starCount >= 2);
            star3Go.gameObject.SetActive(starCount >= 3);
        }
    }

    public void OnClick()
    {
        _mapLevelUI.OnLevelButtonClick(levelID);
    }
}
